This example displays the amount of total battery time in hours and minutes. To run this example, put a SysInfo control and a CommandButton control on a form. Paste this code into the Click event of the CommandButton control, then run the example.
Private Sub Command1_Click()
' BatteryLifeTime Property Example
If SysInfo1.BatteryLifeTime <> &HFFFFFFFF Then
Dim TimeLeft As String
Dim TimeTotal As String
Dim temp
temp = TimeSerial(0, 0, SysInfo1.BatteryLifeTime)
TimeLeft = Format(temp, "h:mm")
temp = TimeSerial(0, 0, SysInfo1.BatteryFullTime)
TimeTotal = Format(temp, "h:mm")
MsgBox TimeLeft & " time left from " & TimeTotal & " total."
Else
MsgBox "Cannot determine remaining battery time."
End If
End Sub